#include "BuildUnitManager.h"

#include "BuildUnit.h"
#include "..\Util.h"

namespace BroodWar
{
	namespace Addon
	{
		BuildUnitManager::BuildUnitManager()
		{
			instance = BWSAL::BuildUnitManager::create();
		}
		
		BuildUnitManager::~BuildUnitManager()
		{
			BWSAL::BuildUnitManager::destroy();
		}
		
		BuildUnitManager::!BuildUnitManager()
		{
			BWSAL::BuildUnitManager::destroy();
		}

		BuildUnitManager^ BuildUnitManager::Instance::get()
		{
			if(s_instance == nullptr)
				s_instance = gcnew BuildUnitManager();
			return s_instance;
		}

		void BuildUnitManager::OnUnitEvade(Unit^ unit)
		{
			instance->onUnitEvade(ConvertUnit(unit));
		}
		
		HashSet<BuildUnit^>^ BuildUnitManager::Units::get()
		{
			return ToHashSet<BWSAL::BuildUnit*, BuildUnit^>(instance->getUnits(), &ConvertBuildUnit);
		}
		
		void BuildUnitManager::ResetPlanningData()
		{
			instance->resetPlanningData();
		}
	}
}
